﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BussModel;
using DataBase;
using System.Data.SqlClient;
using System.Data;

namespace DataManager
{
    /// <summary>
    /// RegisterManager 的摘要描述
    /// </summary>
    public class RegisterManager
    {
        private static RegisterManager instance = null;

        public static RegisterManager Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new RegisterManager();
                }
                return instance;
            }

        }

        public RegisterManager()
        {
            //
            // TODO: 在此加入建構函式的程式碼
            //
        }

        public void InsertRecord(string UserName, string NickName, string Sex,string Salt, string Password, string AgainPassword, string Email, string CellPhone, string BirthDay, string Constellation, string Favorite, DateTime RegisterDateTime)
        {
            RegisterModel model = new RegisterModel();
            model.AgainPassword = AgainPassword;
            model.BirthDay = BirthDay;
            model.CellPhone = CellPhone;
            model.Constellation = Constellation;
            model.Email = Email;
            model.Favorite = Favorite;
            model.Id = Guid.NewGuid();
            model.NickName = NickName;
            model.Password = Password;
            model.Salt = Salt;
            model.RegisterDateTime = RegisterDateTime;
            model.Sex = Sex;
            model.UserName = UserName;
           
            Register.Instance.InsertRecord(model);
        }
        public DataTable GetAllRegisterDataById(string UserName,string Password)
        {
           return  Register.Instance.GetAllRegisterDataById(UserName,Password);
        }
        public DataSet GetRegisterDataByEmailAndFavorite(string UserName,string Favorite, string Email)
        {
            return Register.Instance.GetRegisterDataByEmailAndFavorite(UserName,Favorite, Email);
        }
        public void UpdateUserPassword(string UserName, string Favorite, string Email, string Password)
        {
            RegisterModel model = new RegisterModel();
            model.UserName = UserName;
            model.Favorite = Favorite;
            model.Email = Email;
            model.Password = Password;
            model.AgainPassword = Password;
            Register.Instance.UpdatePasswordByUserNameAndFavoriteAndEmail(model);
         }
    }
}